home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Book Chapters / 10 - Networking / NovelNetwar / windows.c < prev   
Text File  |  1995-05-12  |  4KB  |  227 lines

  1. //    Window handling code....
  2.  
  3.  
  4. #include "NovelNetwar.h"
  5.  
  6.  
  7. void windowsInit(void)
  8. {
  9.     
  10. }
  11.  
  12.  
  13. void windowsStartup(void)
  14. {
  15.  
  16. }
  17.  
  18.  
  19. void windowsShutDown(void)
  20. {
  21.  
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28. void DoMouseDown(EventRecord *theEvent)
  29. {
  30. WindowPtr    whichWindow;
  31. int            windowCode;
  32.  
  33.     switch (windowCode = FindWindow(theEvent->where,&whichWindow)) 
  34.     {
  35.         case inMenuBar:
  36.             DoCommand(MenuSelect(theEvent->where));
  37.             break;
  38.             
  39.         case inSysWindow:
  40.             SystemClick(theEvent,whichWindow);
  41.             break;
  42.             
  43.         case inContent:
  44.             if (whichWindow != FrontWindow())
  45.                 SelectWindow(whichWindow);
  46.             
  47.             else if (IsOurWindow(whichWindow) == noErr)
  48.                 DoContent(whichWindow,theEvent);
  49.             
  50.             break;
  51.         
  52.         case inDrag:
  53.             if (whichWindow != FrontWindow())
  54.                 SelectWindow(whichWindow);
  55.             
  56.             else if (IsOurWindow(whichWindow) == noErr)
  57.                 DoDrag(whichWindow,theEvent);
  58.             
  59.             break;
  60.             
  61.         case inGrow:
  62.             if (whichWindow != FrontWindow())
  63.                 SelectWindow(whichWindow);
  64.             
  65.             else if (IsOurWindow(whichWindow) == noErr)
  66.                 DoGrow(whichWindow,theEvent);
  67.             
  68.             break;
  69.         
  70.         case inZoomIn:
  71.         case inZoomOut:
  72.             if (whichWindow != FrontWindow())
  73.                 SelectWindow(whichWindow);
  74.             
  75.             else if (IsOurWindow(whichWindow) == noErr && TrackBox(whichWindow,theEvent->where,windowCode))
  76.                 DoZoom(whichWindow,windowCode);
  77.             
  78.             break;
  79.         
  80.         case inGoAway:
  81.             if (whichWindow != FrontWindow())
  82.                 SelectWindow(whichWindow);
  83.             
  84.             else if (IsOurWindow(whichWindow) == noErr && TrackGoAway(whichWindow,theEvent->where))
  85.                 DoCloseWindow(whichWindow);
  86.             
  87.             break;
  88.     }        
  89. }
  90.  
  91.  
  92.  
  93.  
  94.  
  95. void DoActivateDeactivate(WindowPtr whichWindow,char adFlag)
  96. {
  97.     if (whichWindow && IsOurWindow(whichWindow) == noErr)
  98.     {
  99.         if (helpIsWindow(whichWindow) == noErr)
  100.         {
  101.             helpActivateWindow(whichWindow,adFlag);
  102.         }
  103.  
  104.         else if (gameplayIsWindow(whichWindow) == noErr)
  105.         {
  106.             gameplayActivateWindow(whichWindow,adFlag);
  107.         }
  108.  
  109.     }
  110. }
  111.  
  112.  
  113.  
  114. void DoZoom(WindowPtr whichWindow,int windowCode)
  115. {
  116.     if (whichWindow && IsOurWindow(whichWindow) == noErr)
  117.     {
  118.     
  119.     }
  120. }
  121.  
  122.  
  123.  
  124. void DoGrow(WindowPtr whichWindow,EventRecord *theEvent)
  125. {
  126.     if (whichWindow && IsOurWindow(whichWindow) == noErr)
  127.     {
  128.         if (helpIsWindow(whichWindow) == noErr)
  129.         {
  130.             helpGrowWindow(whichWindow,theEvent);
  131.         }
  132.     }
  133. }
  134.  
  135.  
  136.  
  137. void DoCloseWindow(WindowPtr whichWindow)
  138. {
  139.     if (whichWindow)
  140.     {
  141.         if (helpIsWindow(whichWindow) == noErr)
  142.         {
  143.             helpCloseWindow(whichWindow);
  144.         }
  145.     }
  146. }
  147.  
  148.  
  149.  
  150. void DoDrag(WindowPtr whichWindow,EventRecord *theEvent)
  151. {
  152. Rect    tempRect;
  153.     
  154.     if (whichWindow && IsOurWindow(whichWindow) == noErr)
  155.     {
  156.         if (helpIsWindow(whichWindow) == noErr)
  157.         {
  158.             helpDragWindow(whichWindow,theEvent);
  159.         }
  160.  
  161.         else if (gameplayIsWindow(whichWindow) == noErr)
  162.         {
  163.             gameplayDragWindow(whichWindow,theEvent);
  164.         }
  165.     }
  166. }
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173. void DoContent(WindowPtr whichWindow,EventRecord *theEvent)
  174. {
  175.     if (whichWindow && IsOurWindow(whichWindow) == noErr)
  176.     {
  177.         if (helpIsWindow(whichWindow) == noErr)
  178.         {
  179.             helpDoContent(whichWindow,theEvent);
  180.         }
  181.  
  182.         else if (gameplayIsWindow(whichWindow) == noErr)
  183.         {
  184.             gameplayDoContent(whichWindow,theEvent);
  185.         }
  186.     }
  187. }
  188.  
  189.  
  190.  
  191.  
  192. void UpdateWindow(WindowPtr whichWindow)
  193. {
  194.     if (whichWindow && IsOurWindow(whichWindow) == noErr)
  195.     {
  196.         if (helpIsWindow(whichWindow) == noErr)
  197.         {
  198.             helpUpdateWindow(whichWindow);
  199.         }
  200.  
  201.         else if (gameplayIsWindow(whichWindow) == noErr)
  202.         {
  203.             gameplayUpdateWindow(whichWindow);
  204.         }
  205.     }
  206. }
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213. OSErr IsOurWindow(WindowPtr theWPtr)
  214. {
  215.     if (!theWPtr)
  216.         return(BADWINDOW);
  217.     
  218.     else if (helpIsWindow(theWPtr) == noErr)
  219.         return(noErr);
  220.     
  221.     else if (gameplayIsWindow(theWPtr) == noErr)
  222.         return(noErr);
  223.     
  224.     else
  225.         return(BADWINDOW);
  226. }
  227.